<?php

class themeComponents extends sfComponents {

    public function executeComment_list(sfWebRequest $request){
        $theme = $this->getVar('theme');
        $this->theme_comments = Doctrine::getTable('ThemeComment')->createQuery()->where('theme_id = ?',$theme->getId())->andWhere('display = 1')->orderBy('created_at asc')->execute();
    }
    
   public function executeLogin_recommend_group(sfWebRequest $request){
       $group_ids = Doctrine::getTable('GroupUser')->createQuery()->where('user_id = ?',$this->getUser()->getAttribute('user_id',0))->execute()->toKeyValueArray('group_id', 'group_id');
       $this->groups = Doctrine::getTable('Jgroup')->createQuery()->where('display = 1')->andWhere('recommend = 1')->andWhereNotIn('id',$group_ids)->orderBy('created_at desc')->limit(5)->execute();
   }
   
   public function executeNologin_recommend_group(sfWebRequest $request){

       $this->groups = Doctrine::getTable('Jgroup')->createQuery()->where('display = 1')->andWhere('recommend = 1')->orderBy('created_at desc')->limit(5)->execute();
   }
   
   public function executeRecommend_comment(sfWebRequest $request){
       $this->recommend_comments = Doctrine::getTable('ThemeComment')->createQuery()->where('display = ?',1)->andWhere('recommend = ?',1)->orderBy('created_at desc')->limit(3)->execute();
   }
}
?>
